/* @(#)testdb.c
 * Time-stamp: <2008-10-11 19:51:01 root>
 * Copyright 2008 Julian Qian
 * Author: root@localhost.localdomain
 * Version: $Id: test1.c,v 0.0 2008/10/07 02:39:58 root Exp $
 * Keywords: 
 */

#include "common.h"

DEFINE_HASHTABLE_INSERT(insert_some, struct key, struct value);
DEFINE_HASHTABLE_SEARCH(search_some, struct key, struct value);
DEFINE_HASHTABLE_REMOVE(remove_some, struct key, struct value);
DEFINE_HASHTABLE_ITERATOR_SEARCH(search_itr_some, struct key);


int main(int argc, char *argv[])
{
	if( get_db_config("config.ini", &gDBConn) ) {
		err_sys("get_db_config");
	}
	
	/* printf("%s/%s/%s/%s\n", gDBConn.hostname,gDBConn.username,gDBConn.password,gDBConn.database); */
	
	db_init(&gDBQ, &gDBConn);

	db_stmt_prepare(&gDBQ);

	ip_t ip = 4234567890;
	ip = 4122006953;
	devid_t devid = 1;
	int stat = 2;
	printf("devid: %u\n", devid);
	printf("devid: %u\n", ip);
	printf("devid: %u\n", stat);
	
	gDBQ.update_ip = ip;
	gDBQ.update_devid = devid;
	gDBQ.update_stat = stat;

	db_stmt_query(gDBQ.update_stmt);
	printf("stmt_update\n");
	db_stmt_query(gDBQ.sel_devid_stmt);
	db_stmt_sel_devid(&gDBQ);
	/*
	if( ! db_stmt_affected(gDBQ.update_stmt) ) {
		printf("db_stmt_insert");
		db_stmt_query(gDBQ.insert_stmt);
	}
	*/
    
    return 0;
}
